<?php

/**
 * This is the model class for table "tbl_product".
 *
 * The followings are the available columns in table 'tbl_product':
 * @property integer $id
 * @property string $model
 * @property string $group
 * @property string $size
 * @property string $description
 * @property string $category
 * @property double $temp_low
 * @property double $temp_high
 * @property double $weight
 * @property string $bearing
 * @property string $voltage
 * @property string $frequency
 * @property string $current
 * @property string $power_consume
 * @property string $speed
 * @property string $air_flow
 * @property string $static_pressure
 * @property string $noise
 * @property string $picture
 */
class Product extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Product the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'tbl_product';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('model', 'required'),
			array('temp_low, temp_high, weight', 'numerical'),
			array('group, size, description, category, bearing, voltage, frequency, current, power_consume, speed, air_flow, static_pressure, noise, picture', 'safe'),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, model, group, category, bearing', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'model' => 'Model',
			'group' => 'Group',
			'size' => 'Size',
			'description' => 'Description',
			'category' => 'Category',
			'temp_low' => 'Temp Low',
			'temp_high' => 'Temp High',
			'weight' => 'Weight',
			'bearing' => 'Bearing',
			'voltage' => 'Voltage',
			'frequency' => 'Frequency',
			'current' => 'Current',
			'power_consume' => 'Power Consume',
			'speed' => 'Speed',
			'air_flow' => 'Air Flow',
			'static_pressure' => 'Static Pressure',
			'noise' => 'Noise',
			'picture' => 'Picture',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('model',$this->model,true);
		$criteria->compare('group',$this->group,true);
		//$criteria->compare('size',$this->size,true);
		//$criteria->compare('description',$this->description,true);
		$criteria->compare('category',$this->category,true);
		//$criteria->compare('temp_low',$this->temp_low);
		//$criteria->compare('temp_high',$this->temp_high);
		//$criteria->compare('weight',$this->weight);
		$criteria->compare('bearing',$this->bearing,true);
		//$criteria->compare('voltage',$this->voltage,true);
		//$criteria->compare('frequency',$this->frequency,true);
		//$criteria->compare('current',$this->current,true);
		//$criteria->compare('power_consume',$this->power_consume,true);
		//$criteria->compare('speed',$this->speed,true);
		//$criteria->compare('air_flow',$this->air_flow,true);
		//$criteria->compare('static_pressure',$this->static_pressure,true);
		//$criteria->compare('noise',$this->noise,true);
		//$criteria->compare('picture',$this->picture,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
        
    public static function getProductsByGroup($group) {
        
    }
	
	public function getId() {
		return $this->id;
	}
	
	public function getModel() {
		return $this->model;
	}
}